/*
 * @version: v1.0
 * @Author: ItLy
 * @Date: 2021-03-13 17:03:29
 * @LastEditors: ItLy
 * @LastEditTime: 2021-03-13 17:52:29
 */
import appConfig from './config/app.config'
const CompressionPlugin = require('compression-webpack-plugin');
export default {
  // Global CSS: https://go.nuxtjs.dev/config-css
  // loading:'./components/loading',
  css: [
    'ant-design-vue/dist/antd.css',
    // '~assets/css/markdown.css',
    { src: "~assets/css/markdown.css", ssr: false },
    { src: "@/static/font/iconfont.css", ssr: false },
    // { src: "~/assets/css/style.css", ssr: false },
    // { src: "~/assets/css/mobile.css", ssr: false },
  ],
  // Global page headers: https://go.nuxtjs.dev/config-head
  head: {
    title: 'itliuyang_ts',
    htmlAttrs: {
      lang: 'zh-CN',
    },
    title: appConfig.meta.title,
    meta: [
      { charset: "utf-8" },
      { name: "viewport", content: "width=device-width, initial-scale=1" },
      {
        name: 'keywords',
        content: appConfig.meta.keywords
      },
      {
        hid: "description",
        name: "description",
        content: appConfig.meta.description
      }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ],
    script: [
      {src: 'https://hm.baidu.com/hm.js?149d1c44ba5ddaa807f6e6db8281297f'},/*引入百度统计的js*/
     ]
 
  },


  // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  plugins: [
    { src: '@/static/font/iconfont.js', ssr: false },
    { src: '@/plugins/baidu.js', mode:'client' },
    { src: '@/plugins/vue-markdown.js', ssr: false },
    { src: '@/plugins/directive', ssr: false },
    { src: '@/plugins/lazyload', ssr: false },
    { src: '@/plugins/axios', ssr: false },
    '@/plugins/antd-ui'
  ],

  // Auto import components: https://go.nuxtjs.dev/config-components
  components: true,

  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: [
    // https://go.nuxtjs.dev/typescript
    '@nuxt/typescript-build',
  ],

  // Modules: https://go.nuxtjs.dev/config-modules
  modules: [
    '@nuxtjs/proxy',
    "@nuxtjs/axios"
  ],
  axios: {
    proxy: true // Can be also an object with default options
  },
  proxy: {
    "/api/": {
      target: "http://127.0.0.1:3008",
      // target: "http://api.itliuyang.com/",
      pathRewrite: {
        "^/api/": "/api/",
        changeOrigin: true
      }
    }
  },
  router: {
    scrollBehavior(to, from, savedPosition) {
      return { x: 0, y: 0 }
    }
  },
  // Build Configuration: https://go.nuxtjs.dev/config-build
  build: {
    // plugins: [
      
    //   new CompressionPlugin({
    //     test: /\.js$|\.html$|\.css/, // 匹配文件名
    //     threshold: 10240, // 对超过10kb的数据进行压缩
    //     deleteOriginalAssets: false // 是否删除原文件
    //   })
    // ],
    extractCSS: { allChunks: true },
    optimization: {
      splitChunks: {
        minSize: 5000,
        maxSize: 100000
      }
    },
  }
}
